package models

import (
	"strconv"
	"time"
	// "golang.org/x/tools/go/types/typeutil"
)

type Users struct {
	ID
	Name   string `json:"name" gorm:"not null;comment:用户名称"`
	Mobile string `json:"mobile" gorm:"not null;index;comment:用户手机号"`
	// Password string `json:"password" gorm:"not null;default:'';comment:用户密码"`
	Password string `json:"password" gorm:"not null;default:'';comment:用户密码"`
	Timestamps
	SoftDeletes
}

func (user Users) GetUid() string {
	return strconv.Itoa(int(user.ID.ID))
}

// 登录记录
type LoginRecords struct {
	ID
	UserID    uint      `json:"user_id" gorm:"not null;comment:用户ID"`
	LoginTime time.Time `json:"login_time" gorm:"not null;comment:登录时间"`
	IP        string    `json:"ip" gorm:"comment:IP地址"`
	UserAgent string    `json:"user_agent" gorm:"comment:用户代理"`
	Timestamps
	SoftDeletes
}

// 用户关注
type Follow struct {
	FollowID    int       `gorm:"primary_key;comment:关注ID"`
	FollowerID  int       `gorm:"index;not null;comment:关注者ID"`
	FollowingID int       `gorm:"index;not null;comment:被关注者ID"`
	CreatedAt   time.Time `gorm:"default:CURRENT_TIMESTAMP;comment:关注时间"`
	SoftDeletes
}
